package cc.vicp.djx314.starfood.service.account.impls;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import cc.vicp.djx314.starfood.dao.account.PersonnelMapper;
import cc.vicp.djx314.starfood.domain.account.Personnel;
import cc.vicp.djx314.starfood.service.account.PersonnelService;
import cc.vicp.djx314.starfood.service.exception.UserNotFoundException;

@Service
public class PersonnelServiceImpl implements PersonnelService {
	@Autowired
	private PersonnelMapper personnelMapper;

	@Override
	@Transactional(readOnly = true)
	public Personnel getPersonnelInfoForSession(String accountName) throws UserNotFoundException {
		Personnel personnel = personnelMapper.getPersonnelInfoForSession(accountName);
		if (personnel == null) {
			throw new UserNotFoundException("账号为:" + accountName + "的用户找不到");
		}
		return personnel;
	}
}